home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Camelot
/
Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip
/
Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf
/
XLisp-Stat
/
Book
/
randu.lsp
< prev
next >
Wrap
Lisp/Scheme
|
1990-10-11
|
389b
|
14 lines
; book p.41
(defun randu (n &optional (seed 12345))
(let ((a (+ (^ 2 16) 3))
(m (^ 2 31)))
(flet ((mod (x m) (- x (* m (floor (/ x m))))))
(do ((i 0 (+ i 1))
(res (list seed)
(cons (mod (* a (first res)) m) res)))
((>= i n)
(/ (rest (reverse res)) m))))))
(def randu (apply #'mapcar #'list (split-list (randu 300) 3)))